<?php
require_once '../models/Product.php';

$action = $_REQUEST['action'];
if ($action == "add-model"){
	$brandID = $_REQUEST['brandID'];
	$modelName = $_REQUEST['modelName'];
	$check = Product::checkModel($brandID,$modelName);
	if ($check == true){
		$re = Product::insertModel($brandID, $modelName);
		if ($re){
			print('<span class="ok">Model is successfully inserted.<a href="ql_series.php">Click Add new series</a></span>');
		}
		else print('<span class="error">System is busy. Please try again later.</span>');	
	}
	else print ('<span class="warning">This Product is already in use.</span>');
	echo  Product::printModelTable('');
}
if ($action == "print-model-drop"){
	$brandID = $_REQUEST['brandID'];
	Product::printModelDrop($brandID);

}
if ($action == "up-model"){
	$modelName=$_POST["modelName"];
	$re=Product::updateModel($modelID,$modelName);
	if($re){
		$mgs="Cập nhật thành công!";
		//$page="update_model.php?modelID=".$modelID;
		//$page="ql_model.php";
		//Product::redirectTo($page);
	}else $mgs="Cập nhật thất bại !!!";
}
?>